package com.zy.controller;

import com.zy.entity.Feedback;
import com.zy.entity.JsonResult;
import com.zy.service.impl.FeedbackServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/app")
public class FeedBackController {
    @Autowired
    FeedbackServiceImpl feedbackService;

    /**
     * 小程序-意见反馈
     *
     * @param userId
     * @param content
     * @return com.zy.entity.JsonResult
     * @author 小宁
     * @date 2021-04-04 13:50
     */
    @PostMapping("/addFeedback")
    @ResponseBody
    public JsonResult addFeedback(int userId, String content) {
        Feedback feedback = new Feedback();
        feedback.setUserId(userId);
        feedback.setContent(content);
        Boolean aBoolean = feedbackService.save(feedback);
        if (aBoolean) {
            return new JsonResult("200", "反馈成功", "");
        } else {
            return new JsonResult("201", "反馈失败，重试", "");
        }
    }
}

